﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SiteAdmin.Master" Inherits="System.Web.Mvc.ViewPage<Beeldbankmvc.ViewModels.ViewCounterViewModel>" %>

<%@ Import Namespace="Beeldbankmvc.Code" %>
<%@ Import Namespace="Beeldbankmvc.Controllers" %>
<%@ Import Namespace="Beeldbankmvc.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">Download overzicht</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script language="javascript" type="text/javascript">
        $(function ()
            {
                $("#MoveRight,#MoveLeft").click(function (event)
                    {
                        var id = $(event.target).attr("id");
                        var selectFrom = id == "MoveRight" ? "#AllCollectionItems" : "#SelectedCollectionItems";
                        var moveTo = id == "MoveRight" ? "#SelectedCollectionItems" : "#AllCollectionItems";

                        var selectedItems = $(selectFrom + " :selected").toArray();
                        $(moveTo).append(selectedItems);
                        selectedItems.remove;
                    }
                );
            }
        );

        $(function ()
            {
                $("#submit").click(function (event)
                    {
                        $("#SelectedCollectionItems *").attr("selected", "selected");
                    }
                );
            }
        );

        /* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */
        /* Written by Mathias Bynens <http://mathiasbynens.be/> */
        jQuery
        (
            function($)
            {
                $.datepicker.regional['nl'] =
                {
                    closeText: 'Sluiten',
                    prevText: '←',
                    nextText: '→',
                    currentText: 'Vandaag',
                    monthNames: ['Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December'],
                    monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
                    dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
                    dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
                    dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
                    weekHeader: 'Wk',
                    dateFormat: 'dd-mm-yy',
                    firstDay: 1,
                    isRTL: false,
                    showMonthAfterYear: false,
                    yearSuffix: ''
                };
                $.datepicker.setDefaults($.datepicker.regional['nl']);
            }
        );

        $(document).ready
        (
            function ()
            {
                var selected = null;

                $('#Report_From_Date').datepicker
                (
                    {
                        beforeShowDay: function (date)
                        {
                            if (selected != null && date.getTime() > selected.getTime() && (date.getTime() - selected.getTime()) < 12 * 24 * 3600 * 1000)
                            {
                                return [true, "highlighted"];
                            }
                            return [true, ""];
                        }
                    }
                );

                $('#Report_To_Date').datepicker
                (
                    {
                        beforeShowDay: function (date)
                        {
                            if (selected != null && date.getTime() > selected.getTime() && (date.getTime() - selected.getTime()) < 12 * 24 * 3600 * 1000)
                            {
                                return [true, "highlighted"];
                            }
                            return [true, ""];
                        }
                    }
                );

                $("#Report_From_Date").datepicker
                (
                    'option', 'onSelect', function ()
                    {
                    }
                );

                $("#Report_To_Date").datepicker
                (
                    'option', 'onSelect', function ()
                    {
                    }
                );

                $('#Report_From_Date').datepicker
                (
                    'setDate', new Date(<%: Model.fromDate.Year %>, <%: Model.fromDate.Month - 1 %>, <%: Model.fromDate.Day %>)
                );

                $('#Report_To_Date').datepicker
                (
                    'setDate', new Date(<%: Model.toDate.Year %>, <%: Model.toDate.Month - 1 %>, <%: Model.toDate.Day %>)
                );

            }
        );
    </script>
    <div id="register">
        <% Html.RenderAction("AdminMenu", "Miscellaneous"); %>
        <h2>Download overzicht</h2>
        <% using (Html.BeginForm())
           { %>
        <table>
            <tr>
                <td>
                    <fieldset>
                        Van:
                        <input id="Report_From_Date" name="Report.From_Date" type="text" style="width: 85px" />
                        Tot:
                        <input id="Report_To_Date" name="Report.To_Date" type="text" style="width: 85px" />
                        <input id="submit" type="submit" value="Filter" class="button" />
                    </fieldset>
                </td>
                <td style="width: 100px">
                </td>
                <td style="vertical-align: middle">
                    <h4><%:Html.ActionLink("Vorige maand", "ViewCounter", "Report", new { standardReport = "PrevMonth" }, null)%></h4>
                    <h4><%:Html.ActionLink("Vorig jaar", "ViewCounter", "Report", new { standardReport = "PrevYear" }, null)%></h4>
                </td>
                <td style="vertical-align: middle">
                    <h4><%:Html.ActionLink("Deze maand", "ViewCounter", "Report", new { standardReport = "CurMonth" }, null)%></h4>
                    <h4><%:Html.ActionLink("Dit jaar", "ViewCounter", "Report", new { standardReport = "CurYear" }, null)%></h4>
                </td>
            </tr>
        </table>
        
        <h2>Bekeken gemonteerde video's</h2>
            
        <div style="display: inline-block; width: 600px">
            <%
               foreach (var item in Model.viewCountersMastered)
               { 
            %>
            <div style="width: 100px; float: left; display: inline-block">
                <%=Url.Image<HomeController>(c => c.DisplayThumb(item.MediaObjectId.ToString()), 65, item.Omschrijving, item.Omschrijving, "/MediaObject/Details/" + AppHelper.convertToUrlTitle(item.Omschrijving, item.MediaObjectId))%>
                <br />
                <%: item.Clicks %>
                maal
            </div>
            <%
                } 
            %>
        </div>
        <div style="width: 100%; text-align: center;">
            <%
                int firstPageIndex = 0;
                while (Model.numberOfRowsMastered > (firstPageIndex * Model.pageSize))
                {
            %>
            <%:Html.ActionLink((firstPageIndex + 1).ToString(), "ViewCounter", "Report", new { masteredPageIndex = firstPageIndex, unmasteredPageIndex = Model.currentPageIndexUnmastered, fotoPageIndex = Model.currentPageIndexFoto, bestandPageIndex = Model.numberOfRowsBestand }, null)%>&nbsp;
            <%
firstPageIndex++;
                }
            %>
        </div>

        <h2>Bekeken ongemonteerde video's</h2>
        <div style="display: inline-block; width: 600px">
            <%
               foreach (var item in Model.viewCountersUnmastered)
               {
            %>
            <div style="width: 100px; float: left; display: inline-block">
                <%=Url.Image<HomeController>(c => c.DisplayThumb(item.MediaObjectId.ToString()), 65, item.Omschrijving, item.Omschrijving, "/MediaObject/Details/" + AppHelper.convertToUrlTitle(item.Omschrijving, item.MediaObjectId))%>
                <br />
                <%: item.Clicks %>
                maal
            </div>
            <% 
                }
            %>
        </div>
        <div style="width: 100%; text-align: center;">
            <%
                int secondPageIndex = 0;
                while (Model.numberOfRowsUnmastered > (secondPageIndex * Model.pageSize))
                {
            %>
            <%:Html.ActionLink((secondPageIndex + 1).ToString(), "ViewCounter", "Report", new { masteredPageIndex = Model.currentPageIndexMastered, unmasteredPageIndex = secondPageIndex, fotoPageIndex = Model.currentPageIndexFoto, bestandPageIndex = Model.numberOfRowsBestand }, null)%>&nbsp;
            <%
secondPageIndex++;
                }
            %>
        </div>

        <h2>Gedownloade foto's</h2>
        <div style="display: inline-block; width: 600px">
            <% 
               foreach (var item in Model.viewCountersFoto)
               { 
            %>
            <div style="width: 100px; float: left; display: inline-block">
                <%=Url.Image<HomeController>(c => c.DisplayThumb(item.MediaObjectId.ToString()), 65, item.Omschrijving, item.Omschrijving, "/MediaObject/Details/" + AppHelper.convertToUrlTitle(item.Omschrijving, item.MediaObjectId))%>
                <br />
                <%: item.Clicks %>
                maal
            </div>
            <% 
                } 
            %>
        </div>
        <div style="width: 100%; text-align: center;">
            <%
                int thirdPageIndex = 0;
                while (Model.numberOfRowsFoto > (thirdPageIndex * Model.pageSize))
                {
            %>
            <%:Html.ActionLink((thirdPageIndex + 1).ToString(), "ViewCounter", "Report", new { masteredPageIndex = Model.currentPageIndexMastered, unmasteredPageIndex = Model.currentPageIndexUnmastered, fotoPageIndex = thirdPageIndex, bestandPageIndex = Model.numberOfRowsBestand }, null)%>&nbsp;
            <%
thirdPageIndex++;
                }
            %>
        </div>

        <h2>Gedownloade bestanden</h2>
        <div style="display: inline-block; width: 600px">
            <% 
               foreach (var item in Model.viewCountersBestand)
               {
            %>
            <div style="width: 100px; float: left; display: inline-block">
                <%=Url.Image<HomeController>(c => c.DisplayThumb(item.MediaObjectId.ToString()), 65, item.Omschrijving, item.Omschrijving, "/MediaObject/Details/" + AppHelper.convertToUrlTitle(item.Omschrijving, item.MediaObjectId))%>
                <br />
                <%: item.Clicks %>
                maal
            </div>
            <% 
                }
            %>
        </div>
        <div style="width: 100%; text-align: center;">
            <%
                int forthPageIndex = 0;
                while (Model.numberOfRowsBestand > (forthPageIndex * Model.pageSize))
                {
            %>
            <%:Html.ActionLink((forthPageIndex + 1).ToString(), "ViewCounter", "Report", new { masteredPageIndex = Model.currentPageIndexMastered, unmasteredPageIndex = Model.currentPageIndexUnmastered, fotoPageIndex = Model.numberOfRowsFoto, bestandPageIndex = forthPageIndex }, null)%>&nbsp;
            <%
forthPageIndex++;
                }
            %>
        </div>
        <% } %>
    </div>
</asp:Content>
